import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsDateString, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, MinLength } from 'class-validator';
import { JobStatus } from '../entities/job.entity';

export class CreateJobDto {
  @ApiProperty({ description: '任务标题', example: '数据分析任务' })
  @IsString()
  @IsNotEmpty()
  @MinLength(3, { message: '任务标题至少需要3个字符' })
  jobTitle: string;

  @ApiProperty({ description: '任务分类', example: 'Data Analysis' })
  @IsString()
  @IsNotEmpty()
  category: string;

  @ApiProperty({ description: '任务描述', example: '这是一个详细的任务描述，需要分析用户行为数据并提供洞察报告' })
  @IsString()
  @IsNotEmpty()
  @MinLength(10, { message: '任务描述至少需要10个字符' })
  description: string;

  @ApiProperty({ description: '交付物', example: '数据分析报告、可视化图表、建议文档' })
  @IsString()
  @IsNotEmpty()
  @MinLength(5, { message: '交付物描述至少需要5个字符' })
  deliverables: string;

  @ApiProperty({ 
    description: '预算信息', 
    example: { 
      currency: 'USD', 
      amount: 1000, 
      minAmount: 500, 
      maxAmount: 2000 
    },
    additionalProperties: true
  })
  budget: Record<string, any>;

  @ApiProperty({ description: '最大预算', required: false, example: 2000 })
  @IsOptional()
  @IsNumber()
  maxBudget?: number;

  @ApiProperty({ description: '截止时间', example: '2024-12-31T23:59:59Z' })
  @IsDateString()
  deadline: string;

  @ApiProperty({ description: '支付类型', example: 'fixed' })
  @IsString()
  @IsNotEmpty()
  paymentType: string;

  @ApiProperty({ description: '优先级', example: 'high' })
  @IsString()
  @IsNotEmpty()
  priority: string;

  @ApiProperty({ description: '技能等级', example: 'intermediate' })
  @IsString()
  @IsNotEmpty()
  skillLevel: string;

  @ApiProperty({ description: '标签', type: [String], example: ['数据分析', 'Python', 'SQL'] })
  @IsArray()
  @IsString({ each: true })
  @IsOptional()
  tags?: string[];

  @ApiProperty({ description: '任务状态', enum: JobStatus, default: JobStatus.OPEN })
  @IsEnum(JobStatus)
  @IsOptional()
  status?: JobStatus;

  @ApiProperty({ description: '是否自动分配', default: false })
  @IsBoolean()
  @IsOptional()
  autoAssign?: boolean;

  @ApiProperty({ description: '是否允许竞价', default: true })
  @IsBoolean()
  @IsOptional()
  allowBidding?: boolean;

  @ApiProperty({ description: '是否允许并行执行', default: false })
  @IsBoolean()
  @IsOptional()
  allowParallelExecution?: boolean;

  @ApiProperty({ description: '是否启用托管', default: true })
  @IsBoolean()
  @IsOptional()
  escrowEnabled?: boolean;

  @ApiProperty({ description: '是否公开', default: true })
  @IsBoolean()
  @IsOptional()
  isPublic?: boolean;

  @ApiProperty({ description: '钱包地址', example: '0x1234567890abcdef' })
  @IsString()
  @IsNotEmpty()
  walletAddress: string;
} 